feat: pre-warm tailscale path to k3s server on game node start#362
feat: pre-warm tailscale path to k3s server on game node start#362Flegma wants to merge 1 commit into
Conversation
The script served by GET /game-server-node/script/:id is the canonical agent-provisioning path (curl | bash from the panel). After a reboot the Tailscale direct path to the k3s server can come up one-way (tx>0, rx0); tailscaled self-reports healthy, so the existing tailscale-state-check passes while the agent cannot reach the control plane: k3s-agent hangs validating the connection, no pods schedule (including game-server-node-connector), and the node shows Offline. Add a best-effort ExecStartPre drop-in (tailscale-prewarm.conf) that, before k3s-agent starts, runs a bounded tailscale ping to the server parsed from K3S_URL, forcing the direct path to establish bidirectionally. Prefixed with - and wrapped in || true so a failed pre-warm can never block k3s-agent from starting. Mirrors 5stack-panel PR #573.
0f50acd to
fcc3b3d
Compare
Code reviewFound 1 issue, now fixed in systemd Fixed by parsing the host with a api/src/game-server-node/game-server-node.controller.ts Lines 717 to 726 in fcc3b3d |
Problem
GET /game-server-node/script/:id(game-server-node.controller.ts) generates thecurl | bashscript the panel gives you to add a game/GPU node. It provisions the node as a k3s agent joining the control plane over Tailscale.After a reboot, the Tailscale direct path to the k3s server can come up one-way (
tx>0, rx 0).tailscaledself-reports healthy (BackendState=Running, emptyHealth), so the existing5stack-tailscale-state-checkpasses every cycle, yet the agent cannot reach the control plane.k3s-agentthen loops onfailed to get CA certs ... context deadline exceeded, never joins the cluster, no pods (includinggame-server-node-connector) schedule, and the node shows Offline in the panel.Observed live: a GPU node stuck ~27 min after a reboot; a manual
tailscale ping <server>re-established the path and it recovered on its own within one retry.Fix
Add a best-effort
ExecStartPredrop-in (tailscale-prewarm.conf, ink3s-agent.service.d) that runs beforek3s-agentstarts: ifK3S_URLis set, it does a boundedtailscale pingto the server, forcing Tailscale's NAT traversal to (re)establish the direct path bidirectionally, so k3s-agent never validates against a dead one-way path.-and wrapped in|| trueso a failed or hung pre-warm can never blockk3s-agentfrom starting (the ping is bounded bytimeout 15).tailscale-state-checklogic or the other drop-ins.Relationship to 5stack-panel#573
This is the canonical agent-provisioning path, so it is the one that protects all future nodes added via the panel. 5stack-panel#573 adds the same pre-warm to the separate
game-node-server-setup.sh(standalone-server setup, where it is a no-op).Testing
K3S_URL=https://100.90.141.113:6443parses to100.90.141.113, the ping ponged, and it is non-blocking.\${...}becomes${...}, bare$Hpreserved);tscclean and backtick balance even.Note
Guards the reboot case (path warmed at startup). It does not add steady-state one-way-path detection to the periodic
tailscale-state-check, which still only inspects tailscaled's self-reported health; that would be a follow-up.